from shapely.geometry import Point, LineString, Polygon
import geojson

# 创建一个Point对象
point = Point((-122.416667, 37.783333))

# 创建一个LineString对象
line = LineString([(0, 0), (1, 1), (2, 1)])

# 创建一个Polygon对象
polygon = Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])

# 将Shapely对象转换为GeoJSON对象
point_geojson = geojson.Feature(geometry=point, properties={})
line_geojson = geojson.Feature(geometry=line, properties={})
polygon_geojson = geojson.Feature(geometry=polygon, properties={})

# 将GeoJSON对象转换为字符串
point_geojson_str = geojson.dumps(point_geojson)
line_geojson_str = geojson.dumps(line_geojson)
polygon_geojson_str = geojson.dumps(polygon_geojson)

print(point_geojson_str)
print(line_geojson_str)
print(polygon_geojson_str)